---
# Tasks to set up varnish

- name: install needed packages
  package: name={{ item }} state=present
  with_items:
  - libsemanage-python
  - varnish
  tags:
  - varnish
  - packages

- name: set some varnishd selinux boolean
  seboolean: name=varnishd_connect_any persistent=yes state=yes
  tags:
  - varnish
  - selinux

- name: install varnish /etc/sysconfig/varnish file (el7
  copy: src=varnish.el7 dest=/etc/sysconfig/varnish owner=root group=root
  notify:
  - restart varnish
  tags:
  - varnish
  when: ansible_distribution_major_version|int == 7

- name: install varnish /etc/sysconfig/varnish file (fedora)
  template: src=varnish.f25.j2 dest=/etc/varnish/varnish.params owner=root group=root
  notify:
  - restart varnish
  tags:
  - varnish
  when: ansible_distribution_major_version|int > 24

- name: install /etc/varnish/default.vcl (proxies)
  template: src={{ varnish_group }}.vcl.j2 dest=/etc/varnish/default.vcl owner=root group=root
  notify:
  - restart varnish
  tags:
  - varnish

- name: make sure varnish is set to enabled on boot
  service: enabled=yes name=varnish
  tags:
  - varnish
